package 笔试.猿辅导;

import java.util.Scanner;
import java.util.Stack;

/**
 * 猿辅导第二题
 * 统计箱子数量
 */
public class BoxCount {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String data = in.nextLine().trim();
        char[] arrs = data.toCharArray();
        Stack<String> stack = new Stack<>();
        for(int i=0;i<data.length();i++){
            char curr = arrs[i];
            if(curr=='['){
                stack.push("[");
            }else{
                if(curr==']'){
                    int peek = 1;
                    while(!stack.peek().equals("[")){
                        peek+=Integer.valueOf(stack.pop());
                    }
                    stack.pop();
                    stack.push(peek+" ");
                }else{
                    int pre = Integer.valueOf(stack.pop());
                    int now = pre*(curr-'0');
                    stack.push(now+"");
                }
            }
        }
        int ret = 0;
        while (!stack.isEmpty()){
            ret+=Integer.valueOf(stack.pop());
        }
        System.out.println(ret);
    }

}
